/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wollongongtemp.ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import wollongongtemp.entity.Customer;

/**
 *
 * @author Wade
 */
@Stateless
public class CustomerBean {
    @PersistenceContext
    private EntityManager em;

    public void createCustomer(Customer customer) {
        em.persist(customer);
    }

    public void updateCustomer(Customer customer) {
        em.merge(customer);
    }

    public List getCustomerList() {
        return em.createNamedQuery("getAllCustomer").getResultList();
    }

    public Customer getCustomer(long id) {
        return (Customer)em.createNamedQuery("findCustomerByID").setParameter("custID", id).getSingleResult();
    }
}
